home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 6886 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4m)
  2. MIME-Version: 1.0
  3. Subject: Re: Timing stuff
  4. References: <9604012043.AA003vp@ozzy.demon.co.uk> <4jsinv$9mi@senator-bedfellow.MIT.EDU>
  5. Content-Type: text/plain; charset=us-ascii
  6. Content-Transfer-Encoding: 7bit
  7. Path: imada.ou.dk!breese
  8. From: breese@imada.ou.dk (Bjorn Reese)
  9. Message-ID: <1996Apr4.123716.19422@imada.ou.dk>
  10. Sender: news@imada.ou.dk
  11. Nntp-Posting-Host: gounod.imada.ou.dk
  12. Organization: Dept. of Math. & Computer Science, Odense University, Denmark
  13. Date: Thu, 4 Apr 1996 12:37:16 GMT
  14. Newsgroups: comp.sys.amiga.programmer
  15.  
  16. > Brian Skreeg (oz@ozzy.demon.co.uk) wrote on Mon, 1 Apr 96 20:43:25 GMT:
  17. > : I'm writing a ircbot in SAS/C and I need to do things based on intervals.
  18. > : ie: if it doesn't have ops then ask at certain (10 secs) intervals for ops
  19. > : etc etc.
  20.  
  21. You may reconsider asking for ops at a certain interval as it's
  22. really annoying if there's huge lag (the bot gets ops but doesn't
  23. discover it until several minutes later and floods the channel with
  24. op requests.) I'd rather suggest that it asks if it receives a
  25. ERR_CHANOPRIVSNEEDED.
  26.  
  27. > :       What would be the best way for implementing such a thing. It's
  28. > : basically just a simple program with an irc file open using TCP: and stdio
  29. > : CON: for seing what it's up to.
  30.  
  31. The most simple way is to use time(). Although this gives a sloopy
  32. timing it is often sufficient. Insert something like this in your
  33. mainloop
  34.  
  35.   if (time(NULL) - lasttime > timedelay) {
  36.     lasttime = time(NULL);
  37.     dofunkystuff();
  38.   }
  39.  
  40. -- 
  41. Bjorn Reese                      Email: breese@imada.ou.dk
  42. Odense University, Denmark       URL:   http://www.imada.ou.dk/~breese
  43.  
  44. "It's getting late in the game to show any pride or shame" - Marillion
  45.